package com.heima.article.controller;

import com.heima.article.dotos.ApArticleDto;
import com.heima.article.dotos.ApArticleSaveDto;
import com.heima.article.dotos.ArticleHomeDto;

import com.heima.article.service.IApArticleService;

import com.heima.constants.ArticleConstants;
import com.heima.user.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController {


    @Autowired
    private IApArticleService apArticleService;

    @PostMapping("/save")
    public ResponseResult save(@RequestBody ApArticleSaveDto dto) {
        return apArticleService.saveApp(dto);
    }
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(dto,ArticleConstants.ARTICLE_TYPE_NORMAL);
    }

    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(dto,ArticleConstants.ARTICLE_TYPE_HOT);
    }

    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(dto,ArticleConstants.ARTICLE_TYPE_TOP);
    }
}